<?php
/**
 * 图片管理
 */
namespace Admin\Controller;

class ImagesController extends CommonController {

    /**
     * 获取图片
     */
    public function getImg($ids) {
        $ids      = strstr($ids, '|') ? explode('|', $ids) : $ids;
        $ids      = is_array($ids) ? join(',', array_filter($ids)) : $ids;
        $imgModel = M('images');
        $ret      = $imgModel->where(sprintf("id in (%s)", $ids))->select();
        return $ret;
    }

    public function delImg(){
        $id=I('get.id');
        $imgModel = M('images');
        if(!isset($id)||empty($id)){
             $this->ajaxReturn(['status'=>false,'msg'=>'参数错误']);
        }
        $ret      = $imgModel->where(sprintf("id = %s", $id))->delete();
        if($ret){
            $this->ajaxReturn(['status'=>true,'msg'=>'删除成功']);
        }else{
            $this->ajaxReturn(['status'=>false,'msg'=>'删除失败']);
        }
    }
}